﻿using Common;
using Common.Dtos;
using Microsoft.AspNetCore.Mvc;
using Sigma.Admin.API.Authoriza;
using Sigma.Admin.API.Services;

namespace Sigma.Admin.API.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class MenuController:ControllerBase
    {
        private readonly IMenuService service;

        public MenuController(IMenuService service)
        {
            this.service = service;
        }

        [HttpGet]
        [PermissionAuthorize("Menu_Get")]
        public async Task<ApiResponse<List<MenuDto>>> GetMenu()
        {
            return await service.GetAllAsync();
        }

        [HttpPost]
        [PermissionAuthorize("Menu_Add")]
        public async Task<ApiResponse> AddMenu(MenuDto menuDto)
        {
            return await service.AddAsync(menuDto);
        }
        [HttpDelete]
        [PermissionAuthorize("Menu_Delete")]
        public async Task<ApiResponse> DeleteMenu(int id)
        {
            return await service.DeleteAsync(id);
        }

    }
}
